package com.dd.cloud.user.enums;

import com.dd.cloud.common.enums.ExceptionEnumInterface;
import com.dd.cloud.common.vo.EnumResultVo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 接口异常枚举封装
 *
 * @author zk
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum ExceptionEnum implements ExceptionEnumInterface {
    ACCOUNT_NOT_FOUND(400, "账号不存在"),
    ORDER_NOT_FOUND(400, "订单不存在"),
    ORDER_IS_PAY(400, "该订单已支付"),
    ORDER_FLOW_IS_PAY(400, "流水已支付"),
    INVALID_ORDER_PARAM(400, "订单金额不符"),
    UPDATE_ORDER_STATUS_ERROR(500, "订单状态修改失败"),

    MEDIA_CLASSIFY_IS_NOT_EXISTS(400, "课堂类型不存在"),
    MEDIA_CLASSIFY_IS_EXISTS(400, "课堂类型已存在"),
    GET_PAY_PARAM_ERROR(500, "获取支付参数失败, 原因:%s"),

    PRES_CREATE_ERROR(400, "处方提交失败, 原因: %s"),

    SHART_WX_ERROR(400, "微信分享失败, 原因: %s"),

    ACCOUNT_IS_NOT_PHAR(400,"该账号没有药房"),

    PHAR_IS_DEL(400,"药房已被删除"),
    PHAR_IS_DISABLE(400,"该药房已被禁用,暂不可使用"),
    ACCOUNT_IS_NOT_USE(400,"该账号暂不可使用,请联系药房管理员");


    private int code;
    private String msg;

    @Override
    public EnumResultVo getMessage() {
        ExceptionEnum exceptionEnum = ExceptionEnum.valueOf(this.name());
        return new EnumResultVo(exceptionEnum.code, exceptionEnum.msg);
    }

    @Override
    public String setMessage(String msg) {
        ExceptionEnum exceptionEnum = ExceptionEnum.valueOf(this.name());
        return String.format(exceptionEnum.getMsg(), msg);
    }
}
